$(function () {
    $("#jqGrid").jqGrid({
        url: baseURL + 'orth/siteUser/list',
        datatype: "json",
        colModel: [
            { label: 'ID', name: 'id_', index: "id_", width: 35, key: true,hidden:true},
            { label: '姓名', name: 'name', width: 75 },
            { label: '性别', name: 'sex', width: 75,formatter: function(value, options, row){
                return value === 0 ?
                    '男' :
                    '女';
            }},
            { label: '手机号', name: 'phone', width: 75 },
            { label: '邮箱', name: 'mail', width: 90 },
            { label: '用户类型', name: 'type', width: 75,formatter: function(value, options, row){
                return value === 1 ?
                    '普通用户' :
                    '医学人士';
            }},
            { label: '科室', name: 'dept', width: 85 },
            { label: '职称', name: 'title', width: 85 },
            { label: '注册日期', name: 'createTime', width: 100,sortable:false}
        ],
        viewrecords: true,

        rowNum: 10,
        rowList : [10,30,50],
        rownumbers: true,
        rownumWidth: 25,
        autowidth:true,
        multiselect: true,
        pager: "#jqGridPager",
        jsonReader : {
            root: "page.list",
            page: "page.currPage",
            total: "page.totalPage",
            records: "page.totalCount"
        },
        prmNames : {
            page:"page",
            rows:"limit",
            order: "order"
        },
        gridComplete:function(){
            //隐藏grid底部滚动条
            $("#jqGrid").closest(".ui-jqgrid-bdiv").css({ "overflow-x" : "hidden" });
        }
    });
    $('.form-horizontal').validationEngine('attach',{
        autoHidePrompt: true,
        autoHideDelay: 2000,
        maxErrorsPerField: 1
    });
});

var vm = new Vue({
    el:'#rrapp',
    data:{
    },
    methods: {
        query: function () {
            vm.reload();
        },
        reload: function () {
            vm.showList = true;
            $(".formError").hide();
            var page = $("#jqGrid").jqGrid('getGridParam','page');
            $("#jqGrid").jqGrid('setGridParam',{
                postData:{'content': ""},
                page:page
            }).trigger("reloadGrid");
        },
        validator: function () {

        }
    }
});